import api from '../../api/api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: '1',
    bidOrderlist: [],
		page: 1,
		row: 10,
    total: 0,
    searchCondition: "",
  },
  onChange(e) {
		let that = this
		that.setData({
			active: e.detail.name,
			page: 1,
			listItems: []
		})
		that.getBigOrderlist()
  },
  onClick(){
    let that = this
    that.getBigOrderlist()
  },
  clearSearch(){
    let that = this
    that.getBigOrderlist()
  },
  getBigOrderlist(params) {
    // 改变this指向  
    let that = this;
    let companyid = wx.getStorageSync('companyid')
    that.setData({
      companyid:companyid,
    })
    let bidInfoReq = {
      companyStatus: that.data.active,
      searchCondition:that.data.searchCondition,
      companyId:that.data.companyid,
      page:that.data.page,
      row:that.data.row
    }
    api.post('/companyInfoApp/findBidInfo', bidInfoReq).then(res => {
      if (res.code == 200){
        that.setData({
          bidOrderlist :res.data
         })
      }
       else{
        wx.showToast({
          icon:'none',
          title: err.message,
          duration: 2000
        })
       }                                                                                                          
    })
    .catch(err => {
    
   })
  },
  onSearch(e){
    let that = this
    that.setData({
      searchCondition: e.detail
    })
    },
	// async getList() {
	// 	try {
	// 		let that = this
	// 		let params = {
	// 			status: that.data.active,
	// 			page: that.data.page,
	// 			row: that.data.row
	// 		}
	// 		console.log('请求参数', params)
	// 		// 请求接口
  //     const data = await that.getBigOrderlist(params)
  //     console.log(data);
	// 		that.setData({
	// 			listItems: that.data.listItems.concat(data.list),
	// 			total: data.total
	// 		})
	// 	} catch (error) {
	// 		console.log(error)
	// 	}
	// },
  serachClick(event) {
  },
  goToMyBack(){
    wx.navigateBack()
  },
  goToUpdataLogistics(){
    wx.redirectTo({
      url:'/pages/updateLogistics/updateLogistics'
    })
  },
  goToReceipt(){
    wx.redirectTo({
      url:'/pages/receipt/receipt'
    })
  },
 goToOrderDetail(){
    wx.redirectTo({
      url:'/pages/orderDetail/orderDetail'
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {//此处接收传递过来的参数wx.navigateTo跳转时传递的参数
		let that = this
    //如果要在页面中使用
    that.setData({
      active: options.active
    })
   that.getBigOrderlist()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
		let that = this
		// console.log('触底')
    if (that.data.page * 10 < that.data.total) {
      that.setData({
        page: that.data.page += 1
      })
      // that.getList()
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})